﻿namespace OleDbDAL.Systems
{
    using DBUtility;
    using IDal.Systems;
    using System;
    using System.Data;

    public class GetTableColCountApp : IGetTableColCount
    {
        public int ReturnTableColCount(string tableName, string StrWhere)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int ReturnTableColCount(string dbName, string tableName, string StrWhere)
        {
            string sQLString = "";
            if (StrWhere != "")
            {
                sQLString = "select count(*) from " + tableName + " " + StrWhere;
            }
            else
            {
                sQLString = "select count(*) from " + tableName;
            }
            DataTable table = DbHelperOledb.Query(dbName, sQLString);
            if (table.Rows.Count > 0)
            {
                return int.Parse(table.Rows[0][0].ToString());
            }
            return 0;
        }
    }
}

